package edu.mercer.sse554.bkp;

/**
 * Convert exceptions between checked and unchecked.<p>
 *
 * Visitor Pattern:<br>
 * 
 * Concrete visitor implementation. All exceptions converted into custom
 * 	BackupUncheckedException or BackupException.<p> 
 *
 * @see BackupErrorConversion
 */

public class BackupErrorConversionVisitor 
	
	implements BackupErrorConversion<BackupException,
									 BackupUncheckedException>
{
	/**
	 * Use factory.<p>
	 * 
	 * @see #factory 
	 */
	
	private BackupErrorConversionVisitor()
	{
		super();
		
	}//constructor
	
	
	/**
	 * Create Visitor: BackupErrorConversionVisitor.<p>
	 * 
	 * @return  new BackupErrorConversionVisitor instance
	 */
	
	public static BackupErrorConversionVisitor factory()
	{
		return new BackupErrorConversionVisitor();
		
	}//method
	
	
	/**
	 * Wrap checked exception inside an un-checked.<p>
	 * 
	 * @param err - BackupException
	 * 
	 * @return  BackupUncheckedException
	 */
	
	@Override
	public BackupUncheckedException visit( final BackupException err ) 
	{		
		return new BackupUncheckedException( err );
	
	}//method


	/**
	 * Wrap unchecked exception inside a checked.<p>
	 * 
	 * @param err - BackupUncheckedException
	 * 
	 * @return  BackupException
	 */
	
	@Override
	public BackupException visit( final BackupUncheckedException err ) 
	{
		return new BackupException( err );
	
	}//method

	
}//class
